<h1>
	<?php echo ($new_topic) ? 'Create a new topic' : 'Reply to “'.html::specialchars($topic->title).'”' ?>
	<?php if ($preview) echo '(preview)' ?>
</h1>

<?php if ($preview) { ?>

	<div id="postpreview">
		<p><a href="#postform">Skip preview</a></p>
		<?php echo Kohana::debug($post) ?>
	</div>

<?php } ?>

<form id="postform" action="<?php echo url::site('pianissiboard/post'.($new_topic ? '' : '/topic/'.$topic->id)) ?>#formerrors" method="post">

	<?php if ( ! empty($formerrors)) include Kohana::find_file('views', 'elements/formerrors') ?>

	<fieldset>
		<legend>What do you want to say?</legend>

		<?php if ($new_topic) { ?>

			<p class="<?php if (isset($formerrors['title'])) echo 'alert' ?>">
				<label for="title">Topic title<abbr title="required">*</abbr></label>
				<input id="title" name="title" type="text" value="<?php echo html::specialchars($postform->title) ?>" size="50" maxlength="100" />
			</p>

		<?php } ?>

		<p class="<?php if (isset($formerrors['post'])) echo 'alert' ?>">
			<label for="post">Your post<abbr title="required">*</abbr></label>
			<textarea id="post" name="post" rows="10" cols="50"><?php echo html::specialchars($postform->post) ?></textarea>
		</p>

	</fieldset>

	<fieldset>
		<legend>Who are you?</legend>

		<p class="<?php if (isset($formerrors['author'])) echo 'alert' ?>">
			<label for="author">Your name<abbr title="required">*</abbr></label>
			<input id="author" name="author" type="text" value="<?php echo html::specialchars($postform->author) ?>" size="30" maxlength="100" />
		</p>

		<p class="<?php if (isset($formerrors['email'])) echo 'alert' ?>">
			<label for="email">Your e-mail<?php if (Kohana::config('pianissiboard.require_email') === TRUE) echo '<abbr title="required">*</abbr>' ?></label>
			<input id="email" name="email" type="text" value="<?php echo html::specialchars($postform->email) ?>" size="30" maxlength="100" />
		</p>

		<p class="<?php if (isset($formerrors['website'])) echo 'alert' ?>">
			<label for="website">Your website</label>
			<input id="website" name="website" type="text" value="<?php echo html::specialchars($postform->website) ?>" size="30" maxlength="100" />
		</p>

		<p>
			<input id="remember" name="remember" type="checkbox" <?php if ($postform->remember) echo 'checked="checked"' ?> />
			<label for="remember">Remember my personal data for next time</label>
		</p>

	</fieldset>

	<fieldset>
		<legend>Confirm your post</legend>

		<?php if (Kohana::config('pianissiboard.enable_captcha') === TRUE AND ! Captcha::instance()->promoted()) { ?>

			<p class="<?php if (isset($formerrors['captcha'])) echo 'alert' ?>">
				<label for="captcha">
					Captcha<abbr title="required">*</abbr>
					<?php echo Captcha::instance()->render() ?>
				</label>
				<input id="captcha" name="captcha" type="text" size="8" />
			</p>

		<?php } ?>

		<p>
			<input name="preview" type="submit" value="Preview" />
			or <input name="confirm" type="submit" value="<?php echo ($new_topic) ? 'Create topic' : 'Post reply' ?>" />
		</p>

	</fieldset>

</form>